package com.dom.domweb.modular.controller.sysmger;

import com.dom.common.model.vo.basic.*;
import com.dom.domweb.common.RspModel;
import com.dom.domweb.common.TabPager;
import com.dom.domweb.dao.service.ITGoodStandardTblService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品规格控制器
 */
@RestController
@RequestMapping("/base")
public class StandardController {

    @Autowired
    private ITGoodStandardTblService standardTblService;

    @RequestMapping("/getStandardInfoList")
    public TabPager getStandardInfoList(@RequestParam("limit")int limit, @RequestParam("page")int page){
        B129R request = new B129R();
        request.setPn(page);
        request.setPs(limit == 0 ? 20 : limit);
        B129A result = standardTblService.getStandardInfoList(request);
        return new TabPager(result.getStandardData(),result.getTotalNum());
    }

    @RequestMapping("/getAllStandardInfo")
    public RspModel getAllStandardInfo(){
        B129A result = standardTblService.getAllStandardInfo();
        return new RspModel(result.getStandardData());
    }

    @RequestMapping("/getStandardInfoByCode")
    public RspModel getStandardInfoByCode(@RequestParam("id") String id){
        B123A result = standardTblService.getStandardInfoByCode(id);
        return new RspModel(result);
    }
    @RequestMapping("/insertStandardInfo")
    public RspModel insertStandardInfo(@RequestBody B120R request){
        return standardTblService.insertStandardInfo(request);
    }

    @RequestMapping("/updateStandardInfo")
    public RspModel editStandardInfo(@RequestBody B120R request){
        return standardTblService.editStandardInfo(request);
    }

    @RequestMapping("/standardInfoDel")
    public RspModel standardInfoDel(@RequestParam("id")String id){
        return standardTblService.standardInfoDel(id);
    }
}
